<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
// /
Route::get('/',function(){
    return redirect('admin/login');
});

//后台登录
Route::get('admin/login', 'Admin\LoginController@showLoginForm');
Route::post('admin/login', 'Admin\LoginController@login');
Route::get('admin/logout', 'Admin\LoginController@logout');

//管理员管理路由
Route::group(['prefix' => 'admin', 'namespace' => 'Admin', 'middleware'=>'auth.admin'], function (){
    Route::get('', 'IndexController@index');
    Route::resource('adminuser', 'AdminController');
    Route::resource('roles', 'RoleController');
    Route::resource('permissions', 'PermissionsController');
    Route::get('logs', 'AdminController@getLogs');
    Route::post('logs', 'AdminController@getLogs');
    Route::patch('roleAdd/{admin}', 'AdminController@roleAdd');
});

//单页管理路由
Route::group(['prefix' => 'admin/spa', 'namespace' => 'Admin', 'middleware'=>'auth.admin'], function (){
    Route::get('lst', 'SpaController@lst');
    Route::get('create','SpaController@create');
    Route::get('{id}/edit','SpaController@edit');
    Route::post('store','SpaController@store');
    Route::post('update','SpaController@update');
    Route::post('upload','SpaController@upload');
    Route::delete('deleteimage','SpaController@deleteImage');
    Route::get('getgoodsdata','SpaController@getGoodsData');
    Route::delete('{id}/clearcache','SpaController@clearCache');
});

